/* 
   Francois
   Made by ups2000ups
   Cleaned by wackyracer
*/

void npc(Player @player, NPC @npc) {
	int state = npc.getState();
	int type = npc.getSelected();
	npc.setVariable("type", type);

	string [] menu 		= {"Make a Wand", "Make a Staff", "Make a Glove", "Upgrade a Glove", "Upgrade a Hat"};
	int menux = 5; // the amount of options in the menu

	int [] _temp				= {0,0,0,0,0,0,0,0,0,0};
	int [] _tempinfo			= {0,0,0,0,0,0,0,0,0,0};
	int [] _tempinfox			= {0,0,0,0,0,0,0,0,0,0};
	int z = 0;

	// -------------------------------- Make a wand
	int [] mw		= {1372005, 1372006, 1372002, 1372004, 1372003, 1372001, 1372000, 1372007};
	int mwx 		= 8;
	string [] mwinfo	= {"(level limit : 8, all)", "(level limit : 13, all)", "(level limit : 18, all)", "(level limit : 23, magican)", "(level limit : 28, magican)", "(level limit : 33, magican)", "(level limit : 38, magican)", "(level limit : 48, magican)"};

	int [] _WoodenWand		= {8,4003001,0001000,0000000,0000000,0000000,0000000,1372005};
	int [] _WoodenWandinfo		= {0,5      ,0      ,0      ,0      ,0      ,0      ,999};	
	int [] _WoodenWandinfox		= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _HardwoodWand		= {8,4003001,4000001,0003000,0000000,0000000,0000000,1372006};
	int [] _HardwoodWandinfo	= {0,10     ,50     ,0      ,0      ,0      ,0      ,999};	
	int [] _HardwoodWandinfox	= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _MetalWand		= {8,4011001,4000009,4003000,0005000,0000000,0000000,1372002};
	int [] _MetalWandinfo		= {0,1      ,30     ,5      ,0      ,0      ,0      ,999};	
	int [] _MetalWandinfox		= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _IceWand			= {8,4011002,4003002,4003000,0012000,0000000,0000000,1372004};
	int [] _IceWandinfo		= {0,2      ,1      ,10     ,0      ,0      ,0      ,999};	
	int [] _IceWandinfox		= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _MithrilWand 		= {8,4011002,4021002,4003000,0030000,0000000,0000000,1372003};
	int [] _MithrilWandinfo		= {0,3      ,1      ,10     ,0      ,0      ,0      ,999};	
	int [] _MithrilWandinfox	= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _WizardWand		= {8,4021006,4011002,4011001,4003000,0060000,0000000,1372001};
	int [] _WizardWandinfo		= {0,5      ,3      ,1      ,15     ,0      ,0      ,999};	
	int [] _WizardWandinfox		= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _FairyWand		= {8,4021006,4021005,4021007,4003003,4003000,0120000,1372000};
	int [] _FairyWandinfo		= {0,5      ,5      ,1      ,1      ,20     ,0      ,999};	
	int [] _FairyWandinfox		= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _Cromi			= {9,4011006,4021003,4021007,4021002,4003002,4003000,0200000,1372007};
	int [] _Cromiinfo		= {0,4      ,3      ,2      ,1      ,1      ,30     ,0      ,999};	
	int [] _Cromiinfox		= {0,0      ,0      ,0      ,0      ,0      ,0      ,0      ,1};

	// -------------------------------- Make a staff
	int [] ms		= {1382000, 1382003, 1382005, 1382004, 1382002, 1382001};
	int msx 		= 6;
	string [] msinfo	= {"(level limit : 10, magican)", "(level limit : 15, magican)", "(level limit : 15, magican)", "(level limit : 20, magican)", "(level limit : 25, magican)", "(level limit : 45, magican)"};

	int [] _WoodenStaff			= {8,4003001,0002000,0000000,0000000,0000000,0000000,1382000};
	int [] _WoodenStaffinfo			= {0,5      ,0      ,0      ,0      ,0      ,0      ,999};	
	int [] _WoodenStaffinfox		= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _SapphireStaff			= {8,4021005,4011001,4003000,0002000,0000000,0000000,1382003};
	int [] _SapphireStaffinfo		= {0,1      ,1      ,5      ,0      ,0      ,0      ,999};	
	int [] _SapphireStaffinfox		= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _EmeraldStaff			= {8,4021003,4011001,4003000,0002000,0000000,0000000,1382005};
	int [] _EmeraldStaffinfo		= {0,1      ,1      ,5      ,0      ,0      ,0      ,999};	
	int [] _EmeraldStaffinfox		= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _OldWoodenStaff			= {8,4003001,4011001,4003000,0005000,0000000,0000000,1382004};
	int [] _OldWoodenStaffinfo		= {0,50     ,1      ,10     ,0      ,0      ,0      ,999};	
	int [] _OldWoodenStaffinfox		= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _WizardStaff			= {8,4021006,4021001,4011001,4003000,0012000,0000000,1382002};
	int [] _WizardStaffinfo			= {0,2      ,1      ,1      ,15     ,0      ,0      ,999};	
	int [] _WizardStaffinfox		= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _ArcStaff			= {10,4011001,4021001,4021006,4021005,4003003,4000010,4003000,0180000,1382001};
	int [] _ArcStaffinfo			= {0 ,3      ,5      ,5      ,5      ,1      ,50     ,30     ,0      ,999};	
	int [] _ArcStaffinfox			= {0 ,0      ,0      ,0      ,0      ,0      ,0      ,0      ,0      ,1};

	// -------------------------------- Make a glove
	int [] mg		= {1082019, 1082020, 1082026, 1082051, 1082054, 1082062, 1082081, 1082086};
	int mgx 		= 8;
	string [] mginfo	= {"(level limit : 15, magican)", "(level limit : 20, magican)", "(level limit : 25, magican)", "(level limit : 30, magican)", "(level limit : 35, magican)", "(level limit : 40, magican)", "(level limit : 50, magican)", "(level limit : 60, magican)"};

	int [] _Lemona				= {8,4000021,0007000,0000000,0000000,0000000,0000000,1082019};
	int [] _Lemonainfo			= {0,15     ,0      ,0      ,0      ,0      ,0      ,999};	
	int [] _Lemonainfox			= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _BlueMorrican			= {8,4000021,4011001,0015000,0000000,0000000,0000000,1082020};
	int [] _BlueMorricaninfo		= {0,30     ,1      ,0      ,0      ,0      ,0      ,999};	
	int [] _BlueMorricaninfox		= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _OceanMesana			= {8,4000021,4011006,0020000,0000000,0000000,0000000,1082026};
	int [] _OceanMesanainfo			= {0,50     ,2      ,0      ,0      ,0      ,0      ,999};	
	int [] _OceanMesanainfox		= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _RedLutia			= {8,4000021,4021006,4021000,0025000,0000000,0000000,1082051};
	int [] _RedLutiainfo			= {0,60     ,1      ,2      ,0      ,0      ,0      ,999};	
	int [] _RedLutiainfox			= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _RedNoel				= {8,4000021,4011006,4011001,4021000,0030000,0000000,1082054};
	int [] _RedNoelinfo			= {0,70     ,1      ,3      ,2      ,0      ,0      ,999};	
	int [] _RedNoelinfox			= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _RedArten			= {8,4000021,4021000,4021006,4003000,0040000,0000000,1082062};
	int [] _RedArteninfo			= {0,80     ,3      ,3      ,30     ,0      ,0      ,999};	
	int [] _RedArteninfox			= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _RedPennance			= {8,4021000,4011006,4000030,4003000,0050000,0000000,1082081};
	int [] _RedPennanceinfo			= {0,3      ,2      ,35     ,40     ,0      ,0      ,999};	
	int [] _RedPennanceinfox		= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _SteelManute			= {8,4011007,4011001,4021007,4000030,4003000,0070000,1082086};
	int [] _SteelManuteinfo			= {0,1      ,8      ,1      ,50     ,50     ,0      ,999};	
	int [] _SteelManuteinfox		= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};

	// -------------------------------- upgrade a glove
	int [] ug		= {1082021, 1082022, 1082027, 1082028, 1082052, 1082053, 1082055, 1082056, 1082063, 1082064, 1082082, 1082080, 1082087, 1082088};
	int ugx 		= 14;
	string [] uginfo	= {"(level limit : 20, magican)", "(level limit : 20, magican)", "(level limit : 25, magican)", "(level limit : 25, magican)", "(level limit : 30, magican)", "(level limit : 30, magican)", "(level limit : 35, magican)", "(level limit : 35, magican)", "(level limit : 40, magican)", "(level limit : 40, magican)", "(level limit : 50, magican)", "(level limit : 50, magican)", "(level limit : 60, magican)", "(level limit : 60, magican)"};

	int [] _GreenMorrican			= {8,1082020,4021003,0020000,0000000,0000000,0000000,1082021};
	int [] _GreenMorricaninfo		= {0,1      ,1      ,0      ,0      ,0      ,0      ,999};	
	int [] _GreenMorricaninfox		= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _PurpleMorrican			= {8,1082020,4021001,0025000,0000000,0000000,0000000,1082022};
	int [] _PurpleMorricaninfo		= {0,1      ,2      ,0      ,0      ,0      ,0      ,999};	
	int [] _PurpleMorricaninfox		= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _BloodMesana			= {8,1082026,4021000,0030000,0000000,0000000,0000000,1082027};
	int [] _BloodMesanainfo			= {0,1      ,3      ,0      ,0      ,0      ,0      ,999};	
	int [] _BloodMesanainfox		= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _DarkMesana			= {8,1082026,4021008,0040000,0000000,0000000,0000000,1082028};
	int [] _DarkMesanainfo			= {0,1      ,1      ,0      ,0      ,0      ,0      ,999};	
	int [] _DarkMesanainfox			= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _BlueLutia			= {8,1082051,4021005,0035000,0000000,0000000,0000000,1082052};
	int [] _BlueLutiainfo			= {0,1      ,3      ,0      ,0      ,0      ,0      ,999};	
	int [] _BlueLutiainfox			= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _BlackLutia			= {8,1082051,4021008,0040000,0000000,0000000,0000000,1082053};
	int [] _BlackLutiainfo			= {0,1      ,1      ,0      ,0      ,0      ,0      ,999};	
	int [] _BlackLutiainfox			= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _BlueNoel			= {8,1082054,4021005,0040000,0000000,0000000,0000000,1082055};
	int [] _BlueNoelinfo			= {0,1      ,3      ,0      ,0      ,0      ,0      ,999};	
	int [] _BlueNoelinfox			= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _DarkNoel			= {8,1082054,4021008,0045000,0000000,0000000,0000000,1082056};
	int [] _DarkNoelinfo			= {0,1      ,1      ,0      ,0      ,0      ,0      ,999};	
	int [] _DarkNoelinfox			= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _BlueArten			= {8,1082062,4021002,0045000,0000000,0000000,0000000,1082063};
	int [] _BlueArteninfo			= {0,1      ,4      ,0      ,0      ,0      ,0      ,999};	
	int [] _BlueArteninfox			= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _DarkArten			= {8,1082062,4021008,0050000,0000000,0000000,0000000,1082064};
	int [] _DarkArteninfo			= {0,1      ,2      ,0      ,0      ,0      ,0      ,999};	
	int [] _DarkArteninfox			= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _BluePennance			= {8,1082081,4021002,0055000,0000000,0000000,0000000,01082082};
	int [] _BluePennanceinfo		= {0,1      ,5      ,0      ,0      ,0      ,0      ,999};	
	int [] _BluePennanceinfox		= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _DarkPenance			= {8,1082081,4021008,0060000,0000000,0000000,0000000,1082080};
	int [] _DarkPenanceinfo			= {0,1      ,3      ,0      ,0      ,0      ,0      ,999};	
	int [] _DarkPenanceinfox		= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _GoldManute			= {8,1082086,4011004,4011006,0070000,0000000,0000000,1082087};
	int [] _GoldManuteinfo			= {0,1      ,3      ,5      ,0      ,0      ,0      ,999};	
	int [] _GoldManuteinfox			= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _DarkManute			= {8,1082086,4021008,4011006,0080000,0000000,0000000,1082088};
	int [] _DarkManuteinfo			= {0,1      ,2      ,3      ,0      ,0      ,0      ,999};	
	int [] _DarkManuteinfox			= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};

	// -------------------------------- upgrade a hat
	int [] uh		= {1002065, 1002013};
	int uhx 		= 2;
	string [] uhinfo	= {"(level limit : 30, magican)", "(level limit : 30, magican)"};

	int [] _SteelPride			= {8,1002064,4011001,0040000,0000000,0000000,0000000,1002065};
	int [] _SteelPrideinfo			= {0,1      ,3      ,0      ,0      ,0      ,0      ,999};	
	int [] _SteelPrideinfox			= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};
	int [] _GoldenPride			= {8,1002064,4011006,0050000,0000000,0000000,0000000,1002013};
	int [] _GoldenPrideinfo			= {0,1      ,3      ,0      ,0      ,0      ,0      ,999};	
	int [] _GoldenPrideinfox		= {0,0      ,0      ,0      ,0      ,0      ,0      ,1};


	if(state == 0){
		npc.addText("Do you want to take a look at some items? Well... Any thought of making one? I'm acually a wizard that was banished from the town because I casted an illegal magic. Because of that I've been hiding, doing some business here... Well, that's not really the point. Do you want to do some business with me?");
		npc.sendYesNo();
	}

	else if(state == 1){
		if(npc.getSelected() == YES){
			npc.addText("Alright... It's for both of our own good, right? Choose what you want to do...");
			for(int x = 0; x < menux; x++){
				npc.addText("#b\r\n#L" + (x) + "#" + menu[x] + "#k#l");
			}
			npc.sendSimple();
		}
		else if(npc.getSelected() == NO){
			npc.addText("You don't trust my skills, I suppose... Haha... You should know that I used to be a great wizard. You still can't belive my skills, huh... But just remember that I used to be the great magican of old... Nevermind...");
			npc.sendNext();
			npc.end();
		}	
	}
	else if(state == 2){
		if(type == 0){
			npc.addText("if you gather up the materials for me, I'll make a Wand for you with my magical powers. Now... What kind of a Wand do you want to make?");
			for(int x = 0; x < mwx; x++){
				npc.addText("#b\r\n#L" + (x) + "##t" + mw[x] + "##k " + mwinfo[x] + "#l");
			}
			npc.setState(9);
			npc.sendSimple();
		}
		else if(type == 1){
			npc.addText("if you gather up the materials for me, I'll make a Staff for you with my magical powers. Now... What kind of a Staff do you want to make?");
			for(int x = 0; x < msx; x++){
				npc.addText("#b\r\n#L" + (x) + "##t" + ms[x] + "##k " + msinfo[x] + "#l");
			}
			npc.setState(19);
			npc.sendSimple();
		}
		else if(type == 2){
			npc.addText("if you gather up the materials for me, I'll make a Glove for you with my magical powers. Now... What kind of a Glove do you want to make?");
			for(int x = 0; x < mgx; x++){
				npc.addText("#b\r\n#L" + (x) + "##t" + mg[x] + "##k " + mginfo[x] + "#l");
			}
			npc.setState(29);
			npc.sendSimple();
		}
		else if(type == 3){
			npc.addText("Now... Which Glove do you want to upgrade?");
			for(int x = 0; x < ugx; x++){
				npc.addText("#b\r\n#L" + (x) + "##t" + ug[x] + "##k " + uginfo[x] + "#l");
			}
			npc.setState(39);
			npc.sendSimple();
		}
		else if(type == 4){
			npc.addText("Alright... So which Glove do you want to upgrade?");
			for(int x = 0; x < uhx; x++){
				npc.addText("#b\r\n#L" + (x) + "##t" + uh[x] + "##k " + uhinfo[x] + "#l");
			}
			npc.setState(49);
			npc.sendSimple();
		}
	}


// -------------------------------------------------------------- Make a hat
	else if(state == 50){
		npc.setGetSaveInt(type);

		if(npc.getSaveInt() == 0){
			_temp 		= _SteelPride;
			_tempinfo 	= _SteelPrideinfo;
			_tempinfox 	= _SteelPrideinfox;
		}
		else if(npc.getSaveInt() == 1){
			_temp 		= _GoldenPride;
			_tempinfo 	= _GoldenPrideinfo;
			_tempinfox 	= _GoldenPrideinfox;
		}

		for(int x = 1; x < _temp[0]; x++){
			if(_tempinfo[x] == 999){
				z = x;
			}
		}

		npc.addText("To make one #b#t" + _temp[z] + "##k, I need the following items. " + uhinfo[npc.getSaveInt()] + " and please make sure you don't use an item that's been upgraded as a material for it. What do you think? Do you want one?");
	
		for(int i = 1; i < _temp[0]; i++){
			if(_temp[i] == 0){
				// ignore
			}
			else if(_tempinfo[i] == 0){
				npc.addText("#b\r\n#v4031138# " + _temp[i] + " mesos #k");
			}
			else if(_tempinfo[i] == 999){
				// nothing right now just to not show is as payment
			}
			else if(_tempinfo[i] > 1){
				npc.addText("#b\r\n#v" + _temp[i] + "# " + + _tempinfo[i] + " #t" + _temp[i] + "##k");
			}
			else {
				npc.addText("#b\r\n#v" + _temp[i] + "#  #t" + _temp[i] + "##k");
			}
		} 

		npc.sendYesNo();
	}
	else if(state == 51){

		if(npc.getSaveInt() == 0){
			_temp 		= _SteelPride;
			_tempinfo 	= _SteelPrideinfo;
			_tempinfox 	= _SteelPrideinfox;
		}
		else if(npc.getSaveInt() == 1){
			_temp 		= _GoldenPride;
			_tempinfo 	= _GoldenPrideinfo;
			_tempinfox 	= _GoldenPrideinfox;
		}

		if(npc.getSelected() == YES){

			type = 0;

			for(int x = 1; x < _temp[0]; x++){
				if(_temp[x] == 0){
					// ignore
				}
				else if(_tempinfo[x] == 0){
					if(player.getMesos() < _temp[x]){
						type = 1;
					}
				}
				else if(_tempinfo[x] == 999){
					// nothing just to skip it for now
				}
				else {
					if(player.getItemAmount(_temp[x]) < _tempinfo[x]){
						type = 1;
					}
				}
			}

			if(type == 0){
				for(int x = 1; x < _temp[0]; x++){
					if(_temp[x] == 0){
						// ignore
					}
					else if(_tempinfo[x] == 0){
						player.giveMesos(-_temp[x]);
					}
					else if(_tempinfo[x] == 999){
						player.giveItem(_temp[x], _tempinfox[x]);
					}
					else {
						player.giveItem(_temp[x], -_tempinfo[x]);
					}
				}

				npc.addText("Did it turn out OK? Well it looks like it did! Come back if you want to upgrade something else.");
				npc.sendNext();
				npc.end();
			}
			else if (type == 1){
				npc.addText("Check and see if you have everything you need and if your equipment inventory is full or not.");
				npc.sendNext();
				npc.end();
			}

		}
		else if(npc.getSelected() == NO){
			npc.addText("I make important items for Magicians and sell them for a reasonable price, so take your time and check them all out. You know nothing's free right?");
			npc.sendNext();
			npc.end();
		}
	}



// -------------------------------------------------------------- Make a glove
	else if(state == 40){
		npc.setGetSaveInt(type);

		if(npc.getSaveInt() == 0){
			_temp 		= _GreenMorrican;
			_tempinfo 	= _GreenMorricaninfo;
			_tempinfox 	= _GreenMorricaninfox;
		}
		else if(npc.getSaveInt() == 1){
			_temp 		= _PurpleMorrican;
			_tempinfo 	= _PurpleMorricaninfo;
			_tempinfox 	= _PurpleMorricaninfox;
		}
		else if(npc.getSaveInt() == 2){
			_temp 		= _BloodMesana;
			_tempinfo 	= _BloodMesanainfo;
			_tempinfox 	= _BloodMesanainfox;
		}
		else if(npc.getSaveInt() == 3){
			_temp 		= _DarkMesana;
			_tempinfo 	= _DarkMesanainfo;
			_tempinfox 	= _DarkMesanainfox;
		}
		else if(npc.getSaveInt() == 4){
			_temp 		= _BlueLutia;
			_tempinfo 	= _BlueLutiainfo;
			_tempinfox 	= _BlueLutiainfox;
		}
		else if(npc.getSaveInt() == 5){
			_temp 		= _BlackLutia;
			_tempinfo 	= _BlackLutiainfo;
			_tempinfox 	= _BlackLutiainfox;
		}
		else if(npc.getSaveInt() == 6){
			_temp 		= _BlueNoel;
			_tempinfo 	= _BlueNoelinfo;
			_tempinfox 	= _BlueNoelinfox;
		}
		else if(npc.getSaveInt() == 7){
			_temp 		= _DarkNoel;
			_tempinfo 	= _DarkNoelinfo;
			_tempinfox 	= _DarkNoelinfox;
		}
		else if(npc.getSaveInt() == 8){
			_temp 		= _BlueArten;
			_tempinfo 	= _BlueArteninfo;
			_tempinfox 	= _BlueArteninfox;
		}
		else if(npc.getSaveInt() == 9){
			_temp 		= _DarkArten;
			_tempinfo 	= _DarkArteninfo;
			_tempinfox 	= _DarkArteninfox;
		}
		else if(npc.getSaveInt() == 10){
			_temp 		= _BluePennance;
			_tempinfo 	= _BluePennanceinfo;
			_tempinfox 	= _BluePennanceinfox;
		}
		else if(npc.getSaveInt() == 11){
			_temp 		= _DarkPenance;
			_tempinfo 	= _DarkPenanceinfo;
			_tempinfox 	= _DarkPenanceinfox;
		}
		else if(npc.getSaveInt() == 12){
			_temp 		= _GoldManute;
			_tempinfo 	= _GoldManuteinfo;
			_tempinfox 	= _GoldManuteinfox;
		}
		else if(npc.getSaveInt() == 13){
			_temp 		= _DarkManute;
			_tempinfo 	= _DarkManuteinfo;
			_tempinfox 	= _DarkManuteinfox;
		}

		for(int x = 1; x < _temp[0]; x++){
			if(_tempinfo[x] == 999){
				z = x;
			}
		}

		npc.addText("To make one #b#t" + _temp[z] + "##k, I need the following items. " + uginfo[npc.getSaveInt()] + " and please make sure you don't use an item that's been upgraded as a material for it. What do you think? Do you want one?");
	
		for(int i = 1; i < _temp[0]; i++){
			if(_temp[i] == 0){
				// ignore
			}
			else if(_tempinfo[i] == 0){
				npc.addText("#b\r\n#v4031138# " + _temp[i] + " mesos #k");
			}
			else if(_tempinfo[i] == 999){
				// nothing right now just to not show is as payment
			}
			else if(_tempinfo[i] > 1){
				npc.addText("#b\r\n#v" + _temp[i] + "# " + + _tempinfo[i] + " #t" + _temp[i] + "##k");
			}
			else {
				npc.addText("#b\r\n#v" + _temp[i] + "#  #t" + _temp[i] + "##k");
			}
		} 

		npc.sendYesNo();
	}
	else if(state == 41){


		if(npc.getSaveInt() == 0){
			_temp 		= _GreenMorrican;
			_tempinfo 	= _GreenMorricaninfo;
			_tempinfox 	= _GreenMorricaninfox;
		}
		else if(npc.getSaveInt() == 1){
			_temp 		= _PurpleMorrican;
			_tempinfo 	= _PurpleMorricaninfo;
			_tempinfox 	= _PurpleMorricaninfox;
		}
		else if(npc.getSaveInt() == 2){
			_temp 		= _BloodMesana;
			_tempinfo 	= _BloodMesanainfo;
			_tempinfox 	= _BloodMesanainfox;
		}
		else if(npc.getSaveInt() == 3){
			_temp 		= _DarkMesana;
			_tempinfo 	= _DarkMesanainfo;
			_tempinfox 	= _DarkMesanainfox;
		}
		else if(npc.getSaveInt() == 4){
			_temp 		= _BlueLutia;
			_tempinfo 	= _BlueLutiainfo;
			_tempinfox 	= _BlueLutiainfox;
		}
		else if(npc.getSaveInt() == 5){
			_temp 		= _BlackLutia;
			_tempinfo 	= _BlackLutiainfo;
			_tempinfox 	= _BlackLutiainfox;
		}
		else if(npc.getSaveInt() == 6){
			_temp 		= _BlueNoel;
			_tempinfo 	= _BlueNoelinfo;
			_tempinfox 	= _BlueNoelinfox;
		}
		else if(npc.getSaveInt() == 7){
			_temp 		= _DarkNoel;
			_tempinfo 	= _DarkNoelinfo;
			_tempinfox 	= _DarkNoelinfox;
		}
		else if(npc.getSaveInt() == 8){
			_temp 		= _BlueArten;
			_tempinfo 	= _BlueArteninfo;
			_tempinfox 	= _BlueArteninfox;
		}
		else if(npc.getSaveInt() == 9){
			_temp 		= _DarkArten;
			_tempinfo 	= _DarkArteninfo;
			_tempinfox 	= _DarkArteninfox;
		}
		else if(npc.getSaveInt() == 10){
			_temp 		= _BluePennance;
			_tempinfo 	= _BluePennanceinfo;
			_tempinfox 	= _BluePennanceinfox;
		}
		else if(npc.getSaveInt() == 11){
			_temp 		= _DarkPenance;
			_tempinfo 	= _DarkPenanceinfo;
			_tempinfox 	= _DarkPenanceinfox;
		}
		else if(npc.getSaveInt() == 12){
			_temp 		= _GoldManute;
			_tempinfo 	= _GoldManuteinfo;
			_tempinfox 	= _GoldManuteinfox;
		}
		else if(npc.getSaveInt() == 13){
			_temp 		= _DarkManute;
			_tempinfo 	= _DarkManuteinfo;
			_tempinfox 	= _DarkManuteinfox;
		}

		if(npc.getSelected() == YES){

			type = 0;

			for(int x = 1; x < _temp[0]; x++){
				if(_temp[x] == 0){
					// ignore
				}
				else if(_tempinfo[x] == 0){
					if(player.getMesos() < _temp[x]){
						type = 1;
					}
				}
				else if(_tempinfo[x] == 999){
					// nothing just to skip it for now
				}
				else {
					if(player.getItemAmount(_temp[x]) < _tempinfo[x]){
						type = 1;
					}
				}
			}

			if(type == 0){
				for(int x = 1; x < _temp[0]; x++){
					if(_temp[x] == 0){
						// ignore
					}
					else if(_tempinfo[x] == 0){
						player.giveMesos(-_temp[x]);
					}
					else if(_tempinfo[x] == 999){
						player.giveItem(_temp[x], _tempinfox[x]);
					}
					else {
						player.giveItem(_temp[x], -_tempinfo[x]);
					}
				}

				npc.addText("Did it turn out OK? Well it looks like it did! Come back if you want to upgrade something else.");
				npc.sendNext();
				npc.end();
			}
			else if (type == 1){
				npc.addText("Check and see if you have everything you need and if your equipment inventory is full or not.");
				npc.sendNext();
				npc.end();
			}

		}
		else if(npc.getSelected() == NO){
			npc.addText("I make important items for Magicians and sell them for a reasonable price, so take your time and check them all out. You know nothing's free right?");
			npc.sendNext();
			npc.end();
		}
	}


// -------------------------------------------------------------- Make a glove
	else if(state == 30){
		npc.setGetSaveInt(type);

		if(npc.getSaveInt() == 0){
			_temp 		= _Lemona;
			_tempinfo 	= _Lemonainfo;
			_tempinfox 	= _Lemonainfox;
		}
		else if(npc.getSaveInt() == 1){
			_temp 		= _BlueMorrican;
			_tempinfo 	= _BlueMorricaninfo;
			_tempinfox 	= _BlueMorricaninfox;
		}
		else if(npc.getSaveInt() == 2){
			_temp 		= _OceanMesana;
			_tempinfo 	= _OceanMesanainfo;
			_tempinfox 	= _OceanMesanainfox;
		}
		else if(npc.getSaveInt() == 3){
			_temp 		= _RedLutia;
			_tempinfo 	= _RedLutiainfo;
			_tempinfox 	= _RedLutiainfox;
		}
		else if(npc.getSaveInt() == 4){
			_temp 		= _RedNoel;
			_tempinfo 	= _RedNoelinfo;
			_tempinfox 	= _RedNoelinfox;
		}
		else if(npc.getSaveInt() == 5){
			_temp 		= _RedArten;
			_tempinfo 	= _RedArteninfo;
			_tempinfox 	= _RedArteninfox;
		}
		else if(npc.getSaveInt() == 6){
			_temp 		= _RedPennance;
			_tempinfo 	= _RedPennanceinfo;
			_tempinfox 	= _RedPennanceinfox;
		}
		else if(npc.getSaveInt() == 7){
			_temp 		= _SteelManute;
			_tempinfo 	= _SteelManuteinfo;
			_tempinfox 	= _SteelManuteinfox;
		}


		for(int x = 1; x < _temp[0]; x++){
			if(_tempinfo[x] == 999){
				z = x;
			}
		}

		npc.addText("To make one #b#t" + _temp[z] + "##k, I need the following items. " + mginfo[npc.getSaveInt()] + " and please make sure you don't use an item that's been upgraded as a material for it. What do you think? Do you want one?");
	
		for(int i = 1; i < _temp[0]; i++){
			if(_temp[i] == 0){
				// ignore
			}
			else if(_tempinfo[i] == 0){
				npc.addText("#b\r\n#v4031138# " + _temp[i] + " mesos #k");
			}
			else if(_tempinfo[i] == 999){
				// nothing right now just to not show is as payment
			}
			else if(_tempinfo[i] > 1){
				npc.addText("#b\r\n#v" + _temp[i] + "# " + + _tempinfo[i] + " #t" + _temp[i] + "##k");
			}
			else {
				npc.addText("#b\r\n#v" + _temp[i] + "#  #t" + _temp[i] + "##k");
			}
		} 

		npc.sendYesNo();
	}
	else if(state == 31){


		if(npc.getSaveInt() == 0){
			_temp 		= _Lemona;
			_tempinfo 	= _Lemonainfo;
			_tempinfox 	= _Lemonainfox;
		}
		else if(npc.getSaveInt() == 1){
			_temp 		= _BlueMorrican;
			_tempinfo 	= _BlueMorricaninfo;
			_tempinfox 	= _BlueMorricaninfox;
		}
		else if(npc.getSaveInt() == 2){
			_temp 		= _OceanMesana;
			_tempinfo 	= _OceanMesanainfo;
			_tempinfox 	= _OceanMesanainfox;
		}
		else if(npc.getSaveInt() == 3){
			_temp 		= _RedLutia;
			_tempinfo 	= _RedLutiainfo;
			_tempinfox 	= _RedLutiainfox;
		}
		else if(npc.getSaveInt() == 4){
			_temp 		= _RedNoel;
			_tempinfo 	= _RedNoelinfo;
			_tempinfox 	= _RedNoelinfox;
		}
		else if(npc.getSaveInt() == 5){
			_temp 		= _RedArten;
			_tempinfo 	= _RedArteninfo;
			_tempinfox 	= _RedArteninfox;
		}
		else if(npc.getSaveInt() == 6){
			_temp 		= _RedPennance;
			_tempinfo 	= _RedPennanceinfo;
			_tempinfox 	= _RedPennanceinfox;
		}
		else if(npc.getSaveInt() == 7){
			_temp 		= _SteelManute;
			_tempinfo 	= _SteelManuteinfo;
			_tempinfox 	= _SteelManuteinfox;
		}

		if(npc.getSelected() == YES){

			type = 0;

			for(int x = 1; x < _temp[0]; x++){
				if(_temp[x] == 0){
					// ignore
				}
				else if(_tempinfo[x] == 0){
					if(player.getMesos() < _temp[x]){
						type = 1;
					}
				}
				else if(_tempinfo[x] == 999){
					// nothing just to skip it for now
				}
				else {
					if(player.getItemAmount(_temp[x]) < _tempinfo[x]){
						type = 1;
					}
				}
			}

			if(type == 0){
				for(int x = 1; x < _temp[0]; x++){
					if(_temp[x] == 0){
						// ignore
					}
					else if(_tempinfo[x] == 0){
						player.giveMesos(-_temp[x]);
					}
					else if(_tempinfo[x] == 999){
						player.giveItem(_temp[x], _tempinfox[x]);
					}
					else {
						player.giveItem(_temp[x], -_tempinfo[x]);
					}
				}

				npc.addText("Did it turn out OK? Well it looks like it did! Come back if you want to create something else.");
				npc.sendNext();
				npc.end();
			}
			else if (type == 1){
				npc.addText("Check and see if you have everything you need and if your equipment inventory is full or not.");
				npc.sendNext();
				npc.end();
			}

		}
		else if(npc.getSelected() == NO){
			npc.addText("I make important items for Magicians and sell them for a reasonable price, so take your time and check them all out. You know nothing's free right?");
			npc.sendNext();
			npc.end();
		}
	}

// -------------------------------------------------------------- Make a staff
	else if(state == 20){
		npc.setGetSaveInt(type);

		if(npc.getSaveInt() == 0){
			_temp 		= _WoodenStaff;
			_tempinfo 	= _WoodenStaffinfo;
			_tempinfox 	= _WoodenStaffinfox;
		}
		else if(npc.getSaveInt() == 1){
			_temp 		= _SapphireStaff;
			_tempinfo 	= _SapphireStaffinfo;
			_tempinfox 	= _SapphireStaffinfox;
		}
		else if(npc.getSaveInt() == 2){
			_temp 		= _EmeraldStaff;
			_tempinfo 	= _EmeraldStaffinfo;
			_tempinfox 	= _EmeraldStaffinfox;
		}
		else if(npc.getSaveInt() == 3){
			_temp 		= _OldWoodenStaff;
			_tempinfo 	= _OldWoodenStaffinfo;
			_tempinfox 	= _OldWoodenStaffinfox;
		}
		else if(npc.getSaveInt() == 4){
			_temp 		= _WizardStaff;
			_tempinfo 	= _WizardStaffinfo;
			_tempinfox 	= _WizardStaffinfox;
		}
		else if(npc.getSaveInt() == 5){
			_temp 		= _ArcStaff;
			_tempinfo 	= _ArcStaffinfo;
			_tempinfox 	= _ArcStaffinfox;
		}



		for(int x = 1; x < _temp[0]; x++){
			if(_tempinfo[x] == 999){
				z = x;
			}
		}

		npc.addText("To make one #b#t" + _temp[z] + "##k, I need the following items. " + msinfo[npc.getSaveInt()] + " and please make sure you don't use an item that's been upgraded as a material for it. What do you think? Do you want one?");
	
		for(int i = 1; i < _temp[0]; i++){
			if(_temp[i] == 0){
				// ignore
			}
			else if(_tempinfo[i] == 0){
				npc.addText("#b\r\n#v4031138# " + _temp[i] + " mesos #k");
			}
			else if(_tempinfo[i] == 999){
				// nothing right now just to not show is as payment
			}
			else if(_tempinfo[i] > 1){
				npc.addText("#b\r\n#v" + _temp[i] + "# " + + _tempinfo[i] + " #t" + _temp[i] + "##k");
			}
			else {
				npc.addText("#b\r\n#v" + _temp[i] + "#  #t" + _temp[i] + "##k");
			}
		} 

		npc.sendYesNo();
	}
	else if(state == 21){


		if(npc.getSaveInt() == 0){
			_temp 		= _WoodenStaff;
			_tempinfo 	= _WoodenStaffinfo;
			_tempinfox 	= _WoodenStaffinfox;
		}
		else if(npc.getSaveInt() == 1){
			_temp 		= _SapphireStaff;
			_tempinfo 	= _SapphireStaffinfo;
			_tempinfox 	= _SapphireStaffinfox;
		}
		else if(npc.getSaveInt() == 2){
			_temp 		= _EmeraldStaff;
			_tempinfo 	= _EmeraldStaffinfo;
			_tempinfox 	= _EmeraldStaffinfox;
		}
		else if(npc.getSaveInt() == 3){
			_temp 		= _OldWoodenStaff;
			_tempinfo 	= _OldWoodenStaffinfo;
			_tempinfox 	= _OldWoodenStaffinfox;
		}
		else if(npc.getSaveInt() == 4){
			_temp 		= _WizardStaff;
			_tempinfo 	= _WizardStaffinfo;
			_tempinfox 	= _WizardStaffinfox;
		}
		else if(npc.getSaveInt() == 5){
			_temp 		= _ArcStaff;
			_tempinfo 	= _ArcStaffinfo;
			_tempinfox 	= _ArcStaffinfox;
		}

		if(npc.getSelected() == YES){

			type = 0;

			for(int x = 1; x < _temp[0]; x++){
				if(_temp[x] == 0){
					// ignore
				}
				else if(_tempinfo[x] == 0){
					if(player.getMesos() < _temp[x]){
						type = 1;
					}
				}
				else if(_tempinfo[x] == 999){
					// nothing just to skip it for now
				}
				else {
					if(player.getItemAmount(_temp[x]) < _tempinfo[x]){
						type = 1;
					}
				}
			}

			if(type == 0){
				for(int x = 1; x < _temp[0]; x++){
					if(_temp[x] == 0){
						// ignore
					}
					else if(_tempinfo[x] == 0){
						player.giveMesos(-_temp[x]);
					}
					else if(_tempinfo[x] == 999){
						player.giveItem(_temp[x], _tempinfox[x]);
					}
					else {
						player.giveItem(_temp[x], -_tempinfo[x]);
					}
				}

				npc.addText("Did it turn out OK? Well it looks like it did! Come back if you want to create something else.");
				npc.sendNext();
				npc.end();
			}
			else if (type == 1){
				npc.addText("Check and see if you have everything you need and if your equipment inventory is full or not.");
				npc.sendNext();
				npc.end();
			}

		}
		else if(npc.getSelected() == NO){
			npc.addText("I make important items for Magicians and sell them for a reasonable price, so take your time and check them all out. You know nothing's free right?");
			npc.sendNext();
			npc.end();
		}
	}

// -------------------------------------------------------------- Make a wand
	else if(state == 10){
		npc.setGetSaveInt(type);

		if(npc.getSaveInt() == 0){
			_temp 		= _WoodenWand;
			_tempinfo 	= _WoodenWandinfo;
			_tempinfox 	= _WoodenWandinfox;
		}
		else if(npc.getSaveInt() == 1){
			_temp 		= _HardwoodWand;
			_tempinfo 	= _HardwoodWandinfo;
			_tempinfox 	= _HardwoodWandinfox;
		}
		else if(npc.getSaveInt() == 2){
			_temp 		= _MetalWand;
			_tempinfo 	= _MetalWandinfo;
			_tempinfox 	= _MetalWandinfox;
		}
		else if(npc.getSaveInt() == 3){
			_temp 		= _IceWand;
			_tempinfo 	= _IceWandinfo;
			_tempinfox 	= _IceWandinfox;
		}
		else if(npc.getSaveInt() == 4){
			_temp 		= _MithrilWand;
			_tempinfo 	= _MithrilWandinfo;
			_tempinfox 	= _MithrilWandinfox;
		}
		else if(npc.getSaveInt() == 5){
			_temp 		= _WizardWand;
			_tempinfo 	= _WizardWandinfo;
			_tempinfox 	= _WizardWandinfox;
		}
		else if(npc.getSaveInt() == 6){
			_temp 		= _FairyWand;
			_tempinfo 	= _FairyWandinfo;
			_tempinfox 	= _FairyWandinfox;
		}




		for(int x = 1; x < _temp[0]; x++){
			if(_tempinfo[x] == 999){
				z = x;
			}
		}

		npc.addText("To make one #b#t" + _temp[z] + "##k, I need the following items. " + mwinfo[npc.getSaveInt()] + " and please make sure you don't use an item that's been upgraded as a material for it. What do you think? Do you want one?");
	
		for(int i = 1; i < _temp[0]; i++){
			if(_temp[i] == 0){
				// ignore
			}
			else if(_tempinfo[i] == 0){
				npc.addText("#b\r\n#v4031138# " + _temp[i] + " mesos #k");
			}
			else if(_tempinfo[i] == 999){
				// nothing right now just to not show is as payment
			}
			else if(_tempinfo[i] > 1){
				npc.addText("#b\r\n#v" + _temp[i] + "# " + + _tempinfo[i] + " #t" + _temp[i] + "##k");
			}
			else {
				npc.addText("#b\r\n#v" + _temp[i] + "#  #t" + _temp[i] + "##k");
			}
		} 

		npc.sendYesNo();
	}
	else if(state == 11){

		if(npc.getSaveInt() == 0){
			_temp 		= _WoodenWand;
			_tempinfo 	= _WoodenWandinfo;
			_tempinfox 	= _WoodenWandinfox;
		}
		else if(npc.getSaveInt() == 1){
			_temp 		= _HardwoodWand;
			_tempinfo 	= _HardwoodWandinfo;
			_tempinfox 	= _HardwoodWandinfox;
		}
		else if(npc.getSaveInt() == 2){
			_temp 		= _MetalWand;
			_tempinfo 	= _MetalWandinfo;
			_tempinfox 	= _MetalWandinfox;
		}
		else if(npc.getSaveInt() == 3){
			_temp 		= _IceWand;
			_tempinfo 	= _IceWandinfo;
			_tempinfox 	= _IceWandinfox;
		}
		else if(npc.getSaveInt() == 4){
			_temp 		= _MithrilWand;
			_tempinfo 	= _MithrilWandinfo;
			_tempinfox 	= _MithrilWandinfox;
		}
		else if(npc.getSaveInt() == 5){
			_temp 		= _WizardWand;
			_tempinfo 	= _WizardWandinfo;
			_tempinfox 	= _WizardWandinfox;
		}
		else if(npc.getSaveInt() == 6){
			_temp 		= _FairyWand;
			_tempinfo 	= _FairyWandinfo;
			_tempinfox 	= _FairyWandinfox;
		}

		if(npc.getSelected() == YES){
			type = 0;
			for(int x = 1; x < _temp[0]; x++){
				if(_temp[x] == 0){
					// ignore
				}
				else if(_tempinfo[x] == 0){
					if(player.getMesos() < _temp[x]){
						type = 1;
					}
				}
				else if(_tempinfo[x] == 999){
					// nothing just to skip it for now
				}
				else {
					if(player.getItemAmount(_temp[x]) < _tempinfo[x]){
						type = 1;
					}
				}
			}

			if(type == 0){
				for(int x = 1; x < _temp[0]; x++){
					if(_temp[x] == 0){
						// ignore
					}
					else if(_tempinfo[x] == 0){
						player.giveMesos(-_temp[x]);
					}
					else if(_tempinfo[x] == 999){
						player.giveItem(_temp[x], _tempinfox[x]);
					}
					else {
						player.giveItem(_temp[x], -_tempinfo[x]);
					}
				}
				npc.addText("Did it turn out OK? Well it looks like it did! Come back if you want to create something else.");
				npc.sendNext();
				npc.end();
			}
			else if (type == 1){
				npc.addText("Check and see if you have everything you need and if your equipment inventory is full or not.");
				npc.sendNext();
				npc.end();
			}
		}
		else if(npc.getSelected() == NO){
			npc.addText("I make important items for Magicians and sell them for a reasonable price, so take your time and check them all out. You know nothing's free right?");
			npc.sendNext();
			npc.end();
		}
	}
}